import { axios } from '@/utils/request'
import Vue from 'vue'
import { YEAR_SEMESTER } from '@/store/mutation-types'

/**
 * 存放公共的API请求数据
 * @returns {AxiosPromise}
 */


//----------公共API----------

//-----------学生相关-----------

// 查找没有班级的学生 ；返回 id ,学生姓名
export function getNoClassStudent() {
  return axios({
    url: '/student/stuStudent/noClassStudentsList',
    method: 'get'
  })
}

//-----------学生相关  全查询-----------
export function getClassStudentQueryAll() {
  return axios({
    url: '/student/stuStudent/classStudentQueryAll',
    method: 'get'
  })
}

//-----------教师相关-----------

// 查找所有的教师,id name
export function getTeacherList() {
  return axios({
    url: '/rel_teacher_subject/relTeacherSubject/queryTeacher',
    method: 'get'
  })
}

//第三方学科网相关：例如学科网
// 查找所有的教师,id name
export const getSysThirdOauthRelationship = () =>{
  return axios({
    url: '/oauth/xkwoauth/sysThirdOauthRelationship/getOpenIdByLoginUser',
    method: 'get'
  })
}

//根据科目筛选教师：含老师的教学班级信息
export const queryTeacherListBySubject = (params) => {
  let schoolYearId = Vue.ls.get(YEAR_SEMESTER).schoolYearId
  let semesterId = Vue.ls.get(YEAR_SEMESTER).semesterId
  if(! params.schoolYearId){
    params.schoolYearId = schoolYearId;
  }
  if(! params.semesterId){
    params.semesterId = semesterId;
  }

  return axios({
    // url: '/rel_teacher_subject/relTeacherSubject/queryTeacherListBySubject', //更新替换为下面的方法
    //使用RelClassSubjectTeacherController中的方法，查询老师任课班级情况
    url: '/rel_class_subject_teacher/relClassSubjectTeacher/queryTeacherClassListBySubject',
    method: 'get',
    params: params
  })
}
//根据科目筛选教师：仅仅返回老师姓名和科目
export const queryTeacherNameListBySubject = (params) => {
  let schoolYearId = Vue.ls.get(YEAR_SEMESTER).schoolYearId
  let semesterId = Vue.ls.get(YEAR_SEMESTER).semesterId
  if(! params.schoolYearId){
    params.schoolYearId = schoolYearId;
  }
  if(! params.semesterId){
    params.semesterId = semesterId;
  }

  return axios({
    //仅仅查询老师的姓名和教学科目信息
    url: '/rel_teacher_subject/relTeacherSubject/queryTeacherListBySubject', //更新替换为下面的方法
    //使用RelClassSubjectTeacherController中的方法，查询老师任课班级情况
    // url: '/rel_class_subject_teacher/relClassSubjectTeacher/queryTeacherClassListBySubject',
    method: 'get',
    params: params
  })
}

//科目相关
export function getSubjectList() {
  return axios({
    url: '/rel_teacher_subject/relTeacherSubject/querySubject',
    method: 'get'
  })
}

//------------班级相关-------

export function getAllClass(params) {

  let schoolYearId = Vue.ls.get(YEAR_SEMESTER).schoolYearId
  let semesterId = Vue.ls.get(YEAR_SEMESTER).semesterId
  if(params && params.schoolYearId){
    params.schoolYearId = schoolYearId;
  }
  if(params && ! params.semesterId){
    params.semesterId = semesterId;
  }
  return axios({
    url: 'classes/couClass/queryAllClass',
    method: 'get',
    params: params
  })
}
export function getClassById(classId) {
  return axios({
    url: 'classes/couClass/queryById',
    method: 'get',
    params: {id:classId}
  })
}

//-----------教室相关----------
export function getClassroomDataList() {
  return axios({
    url: '/classroom/facClassroom/listAll',
    method: 'get'
  })
}

//-----------建筑相关----------
export function getBuildingDataList() {
  return axios({
    url: '/building/facBuilding/listAll',
    method: 'get'
  })
}

export const getClassroomList = (params) => {
  return axios({
    url: '/relbuildingclassroom/relBuildingClassroom/selectClassroomByBuildingId',
    method: 'get',
    params: params
  })
}

//-----------学年相关----------
export function getSchoolYearDataList() {
  return axios({
    url: '/schoolyear/couSchoolYear/listAll',
    method: 'get'
  })
}

//-----------学期相关----------
export function getSemesterDataList() {
  return axios({
    url: '/semester/couSemester/listAll',
    method: 'get'
  })
}

//-----------教学计划相关----------
export function getCoursePlanDataList(params) {

  let schoolYearId = Vue.ls.get(YEAR_SEMESTER).schoolYearId
  let semesterId = Vue.ls.get(YEAR_SEMESTER).semesterId
  if(! params.schoolYearId){
    params.schoolYearId = schoolYearId;
  }
  if(! params.semesterId){
    params.semesterId = semesterId;
  }
  return axios({
    url: '/courseplan/couCoursePlan/queryList',
    method: 'get',
    params: params
  })
}

//-----------年级相关----------
export function getAllGrade() {
  return axios({
    url: 'grade/couGrade/queryAllList',
    method: 'get'
  })
}

/**
 * 排课相关
 */

// 课程计划模板
export function getAllCourseScheduleTem() {
  return axios({
    url: '/cou_courseschedule_template/couCoursescheduleTemplate/queryAllList',
    method: 'get'
  })
}
//获取当前学校（租户）下的部门
export function getDepartDataList() {
  return axios({
    url: '/sys/sysDepart/getDepartDataList',
    method: 'get'
  })
}

